1 Public Class FrmPOSRECEIPT_LIST
2     Dim and_SQL As String
3     Private Sub chckcollector_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chckcollector.CheckedChanged
4         
'refresh_List()
5         List_Update()
6         If chckcollector.Checked Then
7             cmbcollector.Enabled = True
8         Else
9             cmbcollector.Enabled = False
10         End If
11     End Sub
12
13     Private Sub FrmPOSRECEIPT_LIST_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
14         chckcollector.Checked = False
15         FILLComboBox(
"SELECT user_ID, Username FROM TBL_Users WHERE Access_Type ='Administrator' OR Access_Type ='Cashier'", cmbcollector)
16         sqlSTR =
"SELECT * FROM TBL_Users "
17         ExecuteSQLQuery(sqlSTR)
18
19         If sqlDT.Rows.Count >
0 Then
20             cmbcollector.Text = sqlDT.Rows(
0)("User_ID") & " - " & sqlDT.Rows(0)("UserName")
21         End If
22         refresh_List()
23         List_Update()
24         Audit_Trail(xUser_ID, TimeOfDay,
"View Sales Receipt Listing")
25     End Sub
26
27     Private Sub DtFrom_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DtFrom.ValueChanged
28         refresh_List()
29         List_Update()
30     End Sub
31
32     Private Sub DtTo_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DtTo.ValueChanged
33         refresh_List()
34         List_Update()
35     End Sub
36
37     Private Sub cmdcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
38         Me.Close()
39     End Sub
40
41     Private Sub refresh_List()
42         If chckcollector.Checked Then
43             and_SQL =
" AND User_ID =" & Split(cmbcollector.Text, " - ")(0)
44         Else
45             and_SQL =
""
46         End If
47         sqlSTR =
"SELECT Order_No AS 'Order No', Receipt_ID as 'Receipt No', Sales_ID as 'ID', VATable as 'Vatable', Total_Sale as 'Total Sale', Amount_Due as 'Amount Due', Void " & _
48                  
"FROM TBL_Sales_Receipt WHERE Receipt_Date >= '" & Format(DtFrom.Value, "MM/dd/yyyy") & "' AND Receipt_Date <= '" & Format(DtTo.Value, "MM/dd/yyyy") & "'"
49         
'MsgBox(sqlSTR)
50         sqlSTR = sqlSTR & and_SQL
51         FillListView(ExecuteSQLQuery(sqlSTR), lstreceipt,
0)
52     End Sub
53
54     Private Sub List_Update()
55         Dim i As Integer
56         For i =
0 To lstreceipt.Items.Count - 1
57             If lstreceipt.Items(i).SubItems(
6).Text = "Yes" Then
58                 lstreceipt.Items(i).ForeColor = Color.Brown
59             End If
60         Next
61     End Sub
62
63
64
65     Private Sub cmdsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
66         grpreceipt.Visible = True
67         txtreceiptid.Select()
68
69     End Sub
70
71     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
72         grpreceipt.Visible = False
73     End Sub
74
75     Private Sub cmdgosearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdgosearch.Click
76         If Not IsNumeric(txtreceiptid.Text) Then
77             MsgBox(
"Only numeric are allowed !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
78             Exit Sub
79         Else
80             sqlSTR =
"SELECT Receipt_ID as 'Receipt No', Sales_ID as 'ID', VATable as 'Vatable', Total_Sale as 'Total Sale', Amount_Due as 'Amount Due', Void " & _
81                      
"FROM TBL_Sales_Receipt WHERE Receipt_ID =" & txtreceiptid.Text
82             FillListView(ExecuteSQLQuery(sqlSTR), lstreceipt,
0)
83         End If
84         grpreceipt.Visible = False
85     End Sub
86
87     Private Sub cmbcollector_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbcollector.SelectedIndexChanged
88         refresh_List()
89         List_Update()
90     End Sub
91
92     Private Sub txtreceiptid_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtreceiptid.TextChanged
93         txtreceiptid.Text = str_Filter(txtreceiptid,
48, 57, 46, 1)
94     End Sub
95
96     Private Sub lstreceipt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstreceipt.Click
97         If lstreceipt.FocusedItem.SubItems(
5).Text = "Yes" Then
98             
'lstreceipt.Items(i).ForeColor = Color.Brown
99             cmdview.Enabled = False
100             cmdvoid.Enabled = False
101         Else
102             cmdvoid.Enabled = True
103             cmdview.Enabled = True
104         End If
105     End Sub
106
107     Private Sub lstreceipt_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstreceipt.SelectedIndexChanged
108
109     End Sub
110
111     Private Sub FrmPOSRECEIPT_LIST_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
112         With Me
113             GBMID.Width = (.Width - (MDIMain.TSHoldRight.Width /
2)) + 60
114             GBMID.Height = .Height - (MDIMain.TSHoldAdvisory.Height +
100)
115
116             .lstreceipt.Width = GBMID.Width -
10
117             .lstreceipt.Height = GBMID.Height - (GBBOTTOM.Height +
20)
118             GBBOTTOM.Top = lstreceipt.Height +
120
119             
'.listorder.Width = GroupBox1.Width - 10
120             
'.listorder.Height = GroupBox1.Height - 51
121             
'.dtpurchased.Left = GroupBox1.Width - .dtpurchased.Width
122             
'.Label3.Left = (.dtpurchased.Left - .Label3.Width) - 2
123             
'.rbreceive.Left = GroupBox1.Width - .rbreceive.Width
124             
'.rbpurchase.Left = (.rbreceive.Left - .rbreceive.Width) - 7
125         End With
126     End Sub
127
128     Private Sub cmdview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdview.Click
129         If lstreceipt.Items.Count >
0 Then
130             lstreceipt.Focus()
131             If lstreceipt.FocusedItem.SubItems(
6).Text = "Yes" Then
132                 MsgBox(
"Can't view the records because it's already been void !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
133                 Exit Sub
134             Else
135                 If lstreceipt.Items.Count >
0 Then
136
137                     lstreceipt.Focus()
138                     FrmPOSVIEW.txtreceiptid.Text = lstreceipt.FocusedItem.SubItems(
1).Text
139                     FrmPOSVIEW.ShowDialog()
140                 End If
141             End If
142         End If
143
144
145     End Sub
146
147     Private Sub cmdvoid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdvoid.Click
148         Dim x As Integer, i As Integer
149         Dim sqlstrx(
5) As String
150         Dim voidNo As Integer
151         lstreceipt.Focus()
152         If x_Access(xUser_Access) Then
153             If lstreceipt.Items.Count >
0 Then
154                 If MsgBox(
"Do you really want to void this receipt", MsgBoxStyle.YesNo, "Sales and Inventory") = MsgBoxResult.Yes Then
155                     If lstreceipt.FocusedItem.SubItems(
6).Text = "No" Then
156                         voidNo = lstreceipt.FocusedItem.Text
157                         sqlSTR =
"INSERT INTO TBL_Sales_Void (Receipt_ID, Sales_ID, Void_Date) " & _
158                                  
"VALUES(" & lstreceipt.FocusedItem.SubItems(1).Text & ", " _
159                                  & lstreceipt.FocusedItem.SubItems(
2).Text & ", " _
160                                  & 
"'" & Format(DTDATE.Value, "MM/dd/yyyy") & "')"
161                         ExecuteSQLQuery(sqlSTR)
162                         sqlSTR =
"UPDATE TBL_Sales_Receipt SET Void ='" & "Yes" & "' WHERE Receipt_ID =" & lstreceipt.FocusedItem.SubItems(1).Text
163                         ExecuteSQLQuery(sqlSTR)
164                         
'return stocks
165                         sqlSTR =
"SELECT * FROM TBL_Sales_Sold_Detail WHERE Sales_ID =" & lstreceipt.FocusedItem.SubItems(2).Text
166                         ExecuteSQLQuery(sqlSTR)
167                         x = sqlDT.Rows.Count
168
169                         For i =
0 To x - 1
170                             ReDim Preserve sqlstrx(i)
171                             sqlstrx(i) =
"UPDATE TBL_Stocks_Balances SET Item_QTY = Item_Qty +" & sqlDT.Rows(i)("Item_Qty") & " WHERE Item_ID =" & sqlDT.Rows(i)("Item_ID")
172                         Next
173                         For i =
0 To x - 1
174                             ExecuteSQLQuery(sqlstrx(i))
175                         Next
176
177                         
'MsgBox(sqlDT.Rows.Count)
178                         refresh_List()
179                         List_Update()
180                     Else
181                         MsgBox(
"This receipt has already been voided !!", MsgBoxStyle.Information, "Sales and Inventory")
182                         Exit Sub
183                     End If
184                     Audit_Trail(xUser_ID, TimeOfDay,
"Receipt Void Receipt No: " & voidNo)
185                     MsgBox(
"Void Success !!", MsgBoxStyle.Information, "Sales and Inventory")
186                 End If
187             End If
188         End If
189     End Sub
190 End Class


Gõ tìm kiếm nhanh...